#include "selectwnddialog.h"
#include "models/command.h"
#include "touchbutton.h"

#include <QApplication>
#include <QEvent>
#include <QGridLayout>
#include <QPushButton>
#include<QDebug>


SelectWndDialog::SelectWndDialog(QMap<int, QString> mpBtn, QWidget *parent)
    : PopupDialog{parent,true,true}
{
    //创建按钮
    QVBoxLayout * pLayout = new QVBoxLayout(this);
    pLayout->setMargin(20);
    pLayout->setContentsMargins(20,20,20,30);

    for(auto it = mpBtn.begin(); it != mpBtn.end();++it)
    {
        int nKey = it.key();
        TouchButton * pBtn = new TouchButton(this);
         pBtn->setText(it.value());
         pBtn->setStyleSheet(QString("QPushButton { \
         background-color: transparent;  \
         color: white;  \
         border: 1px  solid  white; /* 边框宽度为1px，颜色为#A0A0A0 */  \
         border-radius: 0px; /* 边框圆角 */  \
         font: %1px \"微软雅黑\";  \
         } \
         QPushButton:pressed { \
         background-color: #00C8FF; \
         }").arg(int(24*g_xScale)));
         pBtn->setFixedSize(180*g_xScale, 60*g_yScale);
         connect(pBtn,&QPushButton::clicked,this,[=](){
             this->done(nKey);});
         pLayout->addWidget(pBtn);
    }
    setFixedSize(180*g_xScale+40, int(60*g_yScale)*mpBtn.size() + pLayout->spacing()*(mpBtn.size() - 1) + 50);
}
